<template>
  <!-- 二级评论 -->
  <div class="container-cmi">
    <!-- 递归评论 -->
    <commentParent
      v-if="data.parent"
      :data="data.parent"
      @replyCommentitem="replyComment"
    />
    <div class="userInfo_s">
      <span class="name">{{ data.account.nickname }}</span>
      <span class="time">{{
        moment(data.created_at).format("YYYY-MM-DD HH:mm")
      }}</span>
    </div>
    <div class="Content">
      <div class="piclist" v-if="data.pics.length">
        <div class="Pic" v-for="(pic, i) in data.pics" :key="i">
          <img :src="http.defaults.baseURL + pic.url" alt="" />
        </div>
      </div>
      <div v-else></div>
      <p>{{ data.content }}</p>
      <!-- <el-link type="primary" class="reply">回复</el-link> -->
      <div class="display">
        <a href="javascript:;" class="reply" @click="replyComment(data)"
          >回复</a
        >
      </div>
    </div>
  </div>
</template>

<script>
import moment from "moment";
import http from "@/utils/http";
export default {
  name: "commentParent",
  data() {
    return {
      moment,
      http,
    };
  },
  props: {
    data: {
      type: Object,
      default: {},
    },
  },
  methods: {
    replyComment(data) {
      this.$emit("replyCommentitem", data);
    },
  },
};
</script>

<style lang="less" scoped>
.container-cmi {
  margin: 4px 4px 15px 5px;
  border: 1px solid #ccc;
  .userInfo_s {
    padding-left: 10px;
    .name {
      font-size: 14px;
      color: rgb(85, 83, 83);
      margin: 0 5px;
    }
    .time {
      font-size: 12px;
      color: rgb(179, 176, 176);
    }
  }
  .Content {
    margin: 10px 0 0 0;
    padding-left: 10px;
    .reply {
      display: block;
      text-align: right;
      // margin-left: 537px;
      opacity: 0;
    }
    .piclist {
      display: flex;
      justify-content: flex-start;
      .Pic {
        width: 60px;
        height: 60px;
        border: 2px dashed #ccc;
        > img {
          width: 100%;
          height: 100%;
          object-fit: cover;
        }
      }
    }
    .display {
      padding-right: 15px;
      margin-bottom: 10px;
    }
  }
  .Content:hover .reply {
    opacity: 1;
    color: rgb(25, 0, 255);
  }
  .reply:hover {
    text-decoration: underline;
  }
}
</style>